#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat

#FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine AS base
#WORKDIR /app

#FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
#WORKDIR /src
#
#COPY ["CoreDockerImageSizeTest/CoreDockerImageSizeTest.csproj", "CoreDockerImageSizeTest/"]
#RUN dotnet restore "CoreDockerImageSizeTest/CoreDockerImageSizeTest.csproj"
#COPY ..WORKDIR "/src/CoreDockerImageSizeTest" 
#RUN dotnet build "CoreDockerImageSizeTest.csproj" -c Release -o /app/build

FROM FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base
WORKDIR /app
EXPOSE 80
EXPOSE 5000

FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /src
RUN dotnet restore "WebApiCoreFx/WebApiCoreFx.csproj"
COPY . .

RUN dotnet build "WebApiCoreFx.csproj" -c Release -o /app/WebApiCoreFx/build
FROM build AS publish
RUN dotnet publish "WebApiCoreFx.csproj" -c Release -o /app/WebApiCoreFx/publish \
--runtime alpine-x64 \
--self-contained true \
/p:PublishTrimmed=true \

FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-alpine AS final
WORKDIR /app
COPY --from=publish /app/WebApiCoreFx/publish .

ENTRYPOINT ["dotnet","WebApiCoreFx.dll","--urls","http://0.0.0.0:5000"]

#FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
#WORKDIR /app
#COPY . /app
#
#ARG user=root
#USER $user
#EXPOSE 80
#EXPOSE 5000
#CMD [ "/bin/bash" ]
#ENV TZ Asia/Shanghai
#RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#RUN echo 'Asia/Shanghai' >/etc/timezone
#ENTRYPOINT ["dotnet","WebApiCoreFx.dll","--urls","http://0.0.0.0:5000"]